
	**This file generates descriptive stats on ICE removals over time**	

			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
			**	**	**	**	**	**	**	**	**	**	**	**	**
	
*-------------------------------------------------------------------------------
* append  data
*-------------------------------------------------------------------------------


use "allyears.dta", clear


**convert variables to strings for appending
foreach var of varlist portdepart-mostseriouscriminalconviction {
decode `var', gen(`var'2)
drop `var'
rename `var'2 `var'
}

**append
append using "removals 14-17"

**
**Make month variable
**

gen departedmonth=mofd(departedd)
bysort departedmonth: egen monthlyremovals=count(departedd)
format departedmonth %tm

**fix program codes
replace program = removalprogram if program == ""

***
*Create Case Category Indicators and Counts Per Month
***


gen reinst=(category == "[16] Reinstated Final Order") if category != "[8F] Expedited Removal"

gen inadm = (category == "[8C] Excludable / Inadmissible - Administrative Final Order Issued")

gen detdep = (program == "Detention and Deportation")

gen cap = (program == "ERO Criminal Alien Program")

gen er = (category == "[8F] Expedited Removal")

gen return = (category == "[9] VR Under Safeguards")

*monthly counts   
foreach var of varlist reinst inadm detdep cap er return{
bysort departedm: egen monthly`var' = sum(`var')
}


***
**interior removals
***

gen interior = 1 if program != "" & program != "Border Patrol" & ///
 program != "Inspections - Air" & program != "Inspections - Land" & ///
 program != "Inspections - Sea"
replace interior  = 0 if interior != 1 & program != ""
bysort departedmonth: egen monthlyinteriorremovals=sum(interior)

***
**border removals
***

gen border = 1 if program == "Border Patrol" 
bysort departedmonth: egen monthlyborderremovals=sum(border)


**missingness per month--lower than five percent after jan. 2009
gen temp = 1 if program == ""
bysort departedmonth: egen missing = sum(temp)
drop temp
gen propmissing = missing/monthlyremovals

**Year
gen year = year(departedd)

*month tag
bysort departedmonth: gen monthtag = 1 if _n == 1


*how many interior removals in 2014 and 2015?
count if (year == 2014 | year == 2015) & interior == 1
assert r(N) == 161536
tab program if year == 2014 | year == 2015

***
*Figure S5
***

twoway (lpoly monthlyinteriorremovals departedmon if  departedm > m(2009m1) & departedm < m(2016m1) ) ///
(lpoly monthlyborderremovals departedmon if departedm > m(2009m1) & departedm < m(2016m1)) , ///
xlabel(588(12)672, noticks format(%tmCY)) legend(order(1 "Interior" 2 "Border")) xti(Year) yti(Removals Per Month)
graph export "S5.pdf", replace

***
*Figure S6
***

twoway (lpoly monthlyinadm departedmon if departedm > m(2009m1) & departedm < m(2016m1) ) ///
(lpoly monthlyer departedmon if  departedm > m(2009m1) & departedm < m(2016m1)) ///
(lpoly monthlyreturn departedmon if departedm > m(2009m1) & departedm < m(2016m1) ), ///
xlabel(588(12)672, noticks format(%tmCY)) legend(order(1 "Final Order - Inadmissible" 2 ///
"Expedited Removal" 3 "Voluntary Return")) ///
xti(Year) yti(Removals Per Month)
graph export "S6.pdf", replace




